package com.soos.controller;


import com.soos.dto.Result;
import com.soos.service.IFollowService;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/follow")
public class FollowController {
    @Resource
    private IFollowService followService;
    @Resource
    private StringRedisTemplate stringRedisTemplate;

    /**
     * 尝试去关注
     * @param followUserId
     * @param isFollow
     * @return
     */
    @PutMapping("/{id}/{isFollow}")
    public Result tryFollow(@PathVariable("id") Long followUserId,
                            @PathVariable("isFollow") Boolean isFollow) {
        return followService.tryFollow(followUserId,isFollow);
    }

    /**
     * 是否关注
     * @param followUserId
     * @return
     */
    @GetMapping("/or/not/{id}")
    public Result isFollow(@PathVariable("id") Long followUserId) {
        return followService.isFollow(followUserId);
    }

    @GetMapping("/common/{id}")
    public Result commonFollows(@PathVariable("id") Long followUserId){
        return followService.commonFollows(followUserId);
    }

}